package com.synnex.mobile.servier.core.notification.dao.impl;

import com.synnex.mobile.generic.dao.impl.GenericHibernateDaoImpl;
import com.synnex.mobile.servier.core.notification.dao.DeviceTokenDao;
import com.synnex.mobile.servier.core.notification.dto.DeviceToken;
import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User:kerryf
 * To change this template use File | Settings | File Templates.
 */
public class DeviceTokenDaoImpl extends GenericHibernateDaoImpl<DeviceToken, Integer> implements DeviceTokenDao {

    public List<DeviceToken> getTokens() {

        Criteria c = this.getSession().createCriteria(DeviceToken.class);
        return c.list();
    }

    public List<DeviceToken> findToken(String token) {

        Criteria c = this.getSession().createCriteria(DeviceToken.class);
        c.add(Restrictions.eq("token",token));
        return c.list();

    }

    public void addToken(DeviceToken token) {
       this.save(token);
    }
}
